<?php  
                                          
			$grade=$_POST['sltGrade'];
			$year=$_POST['sltYr'];
			$month=$_POST['sltMon'];
			$check=$_POST['rType'];
			
			if($check=="pie"){
			
			include'../logic/Classes/db.php';

            $x=new DbConnect();
            $con=$x->getConnection();

			include'../logic/Classes/reportHandler.php';  
			
			$tot=NULL;
			$x=NULL;
			$z=NULL;
			$w=NULL;
			
			$rep=new ReportHandler();
			$rep->setCon($con);
			$result1=$rep->getGradeIncomeMonthly($grade,$year,$month);
            $result2=$rep->getGradeIncomeMonthly($grade,$year,$month);
			$result3=$rep->getGradeIncomeMonthly($grade,$year,$month);
			$result4=$rep->getGradeIncomeMonthly($grade,$year,$month);
			
			$count=mysql_num_rows($result1);
			
			while($row=mysql_fetch_array($result1)){
			$tot=$tot+$row['income'];//getting total income
			
			}
			
            ?>
 
 <?php  if(!($count==0)) {//check result variable is empty ?>


<script language="JavaScript">
				document.location="http://chart.apis.google.com/chart?chs=600x500&cht=p3&chd=&chd=t:<?php while($row=mysql_fetch_array($result2)){ $x=$x+1;$y=round(($row['income']/$tot)*100);echo $y;if($x<$count){ echo",";}} ?>&chdl=<?php while($row1=mysql_fetch_array($result3)){ $z=$z+1;echo $row1['subject'];if($z<$count){ echo"|";} }   ?>&chl=<?php while($row=mysql_fetch_array($result4)){ $w=$w+1;echo "Rs.".$row['income'].".00";if($w<$count){ echo"|";}} ?>&chma=200&chtt=Monthly+Income+Whole+Collection+Report+of+Grade&chts=676767,20.5&chma=200,0,0,60&chco=0000FF&chts=060644,20.5&chxs=0,000000,11.5&chxt=x";
		
			</script>
			<?php } else { echo "No record related to these parameters";} 

 
 
 } else{ 
 
 header("location:grade_income.php?grade=$grade&year=$year&month=$month"); 
 
 
 } 
 
 

 
 ?>